#ifndef CHATWINDOW_H
#define CHATWINDOW_H

#include <QWidget>
#include <QTcpSocket>
#include <QObject>
#include <QFile>
#include <QTimer>

namespace Ui {
class chatWindow;
}

class chatWindow : public QWidget
{
    Q_OBJECT

public:
    explicit chatWindow(QWidget *parent = nullptr);
    explicit chatWindow(const QString&selfnam,const QString&selfacc,const QString&frinam,const QString&friacc);
    explicit chatWindow(const QString&selfnam,const QString&selfacc,const QString&time);
    ~chatWindow();
    void sendChatMessage(const QString&message);
    void getnames(const QString&selfname,const QString&friname);
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void getselfaccount(const QString&acc);
    void getfriaccount(const QString&acc);
    void showmessage(const QString&message);

protected:
      //添加事件过滤器
     bool eventFilter(QObject *target,QEvent *event);

public slots:
    void slotConnected();
    void slotDisconnected();
    void onReadyRead();

private slots:
    void on_pushButton_clicked();
    void on_toolButton_clicked();
    void on_toolButton_2_clicked();

    void on_toolButton_4_clicked();

    void on_toolButton_3_clicked();
private:
    Ui::chatWindow *ui;
    int port;
    QString selfname;
    QString friname;
    QString selfaccount;
    QString friaccount;
    QTcpSocket *tcpSocket;
    QPoint windowPos;
    QPoint mousePos;
    QPoint dPos;
    QString chattype;
    QString filename;
    qint64 fileSize;
    qint64 sendSize;

    QTimer myTimer;



};

#endif // CHATWINDOW_H
